import logging
from redis import StrictRedis


class Config(object):
    """工程配置信息"""
    SECRET_KEY = 'EjpNVSNQTyGi1VvWECj9TvC/+kq3oujee2kTfQUs8yCM6xX9Yjq52v54g+HVoknA'

    # mysql配置信息
    SQLALCHEMY_DATABASE_URI = 'mysql+mysqlconnector://root:mysql@127.0.0.1:3306/information'
    SQLALCHEMY_TRACK_MODIFICATIONS = False
    SQLALCHEMY_COMMIT_ON_TEARDOWN = True

    # redis配置信息
    REDIS_HOST = '127.0.0.1'
    REDIS_PORT = 6379

    # flask_session的配置信息
    SESSION_TYPE = 'redis'  # 指定session保存在redis中
    SESSION_USE_SIGNER = True  # 让cookies中的session_id被加密签名处理
    SESSION_REDIS = StrictRedis(host=REDIS_HOST, port=REDIS_PORT)
    PERMANENT_SESSION_LIFETIME = 86400  # 设置session的有效时间,单位为秒

    # 设置默认日志输出级别
    LOG_LEVEL = logging.DEBUG


class DevelopmentConfig(Config):
    """开发模式下的配置"""
    DEBUG = True


class ProductionConfig(Config):
    """生产模式下的配置"""
    DEBUG = True
    LOG_LEVEL = logging.WARNING


class TestingConfig(Config):
    """单元测试下的配置"""
    DEBUG = True
    TESTING = True


config = {
    'development': DevelopmentConfig,
    'prodution': ProductionConfig,
    'testing': TestingConfig
}
